package com.feicheng.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.Client;
import com.feicheng.persistence.service.IClientService;
import com.feicheng.service.IFClientService;

@Service
public class FClientServiceImpl implements IFClientService {
	
	
	
	@Autowired
	IClientService clientService;

	@Override
	public ResultInfo getClient(Integer clientId) {
		
		//以client_id为条件取得client的详细信息
		
		
		Client client = clientService.getById(clientId);
		
		
		return ResultInfo.success(client);
	}

	@Override
	public ResultInfo getClientByPage(Client client, Integer current, Integer size) {
		
		//client表的分页查询
		
		Page<Client> page = new Page<Client>(current, size);
		
		QueryWrapper<Client> queryWrapperClient = new QueryWrapper<>();
		
		queryWrapperClient.gt("client_id", 0);
		
		//条件查询
		
		//以姓名为条件分页查询
		if (null != client.getName()) {
			
			queryWrapperClient.like("name", client.getName());
		
		}
		
		//以账号为条件分页查询
		
		if (null != client.getAccount()) {
			
			queryWrapperClient.like("account", client.getAccount());
			
		}
		
		 return ResultInfo.success(clientService.page(page, queryWrapperClient));
	}

}


